package com.jeesite.modules.fl.entity;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.modules.sys.entity.Area;

@Table(name = "fl_appointment", alias = "a", columns = {
        @Column(name = "id", attrName = "id", label = "id", isPK = true),
        @Column(name = "no", attrName = "no", label = "预约编号"),
        @Column(name = "leaguer", attrName = "leaguer.id", label = "预约人"),
        @Column(name = "area", attrName = "area.areaCode", label = "地区"),
        @Column(name = "clinic", attrName = "clinic.id", label = "诊所"),
        @Column(name = "scheduled_time", attrName = "scheduledTime", label = "预约日期"),
        @Column(name = "department", attrName = "department", label = "科室"),
        @Column(name = "appointment_status", attrName = "appointmentStatus", label = "预约状态"),
        @Column(name = "ampm", attrName = "ampm", label = "上下午"),
        @Column(name = "doctor", attrName = "doctor.id", label = "医生"),
        @Column(name = "time", attrName = "time", label = "时间"),
        @Column(name = "finish_time", attrName = "finishTime", label = "服务完成时间"),
        @Column(name = "time_period", attrName = "timePeriod", label = "时间段"),
        @Column(name = "reason", attrName = "reason", label = "理由"),
		@Column(name = "is_evaluate", attrName = "isEvaluate", label = "是否评价"),
		@Column(name = "is_end_poor_rating", attrName = "isEndPoorRating", label = "是否处理差评"),
        @Column(includeEntity = DataEntity.class),
	},joinTable = {
        @JoinTable(type = Type.LEFT_JOIN, entity = Leaguer.class, alias = "l", on = "l.id = a.leaguer", attrName = "leaguer", columns = {@Column(name = "name", label = "名称", queryType=QueryType.LIKE),@Column(name = "cellphone", label = "手机号", queryType=QueryType.LIKE)}),
        @JoinTable(type = Type.LEFT_JOIN, entity = Area.class, alias = "r", on = "r.area_code = a.area", attrName = "area", columns = {@Column(name = "area_name", label = "名称")}),
        @JoinTable(type = Type.LEFT_JOIN, entity = Clinic.class, alias = "c", on = "c.id = a.clinic", attrName = "clinic", columns = {@Column(name = "name", label = "名称"),@Column(name = "short_name", label = "简称")}),
        @JoinTable(type = Type.LEFT_JOIN, entity = Doctor.class, alias = "d", on = "d.id = a.doctor", attrName = "doctor", columns = {@Column(name = "name", label = "名称")}),
	}, orderBy = "a.update_date DESC"
)
public class Appointment extends DataEntity<Appointment>{
	private static final long serialVersionUID = 1L;
	
	private String no;
	private Leaguer leaguer;
	private Area area;
	private Clinic clinic;
	private Date scheduledTime;
	private String department;
	private String appointmentStatus;
	private String ampm;
	private Doctor doctor;
	private Date time;
	private Date finishTime;
	private String reason;
	private String timePeriod;
	private List<ActionRecord> records;
	private List<Evaluate> evaluateList = ListUtils.newArrayList();		// 评价
	private List<EvaluateDetail> evaluateDetailList = ListUtils.newArrayList();		// 评价明细
	private String score1;
	private String score2;
	private String score3;
	private String score4;
	private String evaluateDetail;
	private String isEvaluate;
	private String evaluateLevel;//评论等级：1：好评，2：差评
	private String isEndPoorRating;//是否处理差评: 0:为处理完成，1处理完成
	
	public Appointment(){
		super();
	}
	
	public Appointment(String id){
		super(id);
	}

	@ExcelField(title="预约者", sort=2)
	public Leaguer getLeaguer() {
		return leaguer;
	}

	public void setLeaguer(Leaguer leaguer) {
		this.leaguer = leaguer;
	}

	@ExcelField(title="所在地区", sort=3)
	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	@ExcelField(title="诊所", sort=4)
	public Clinic getClinic() {
		return clinic;
	}

	public void setClinic(Clinic clinic) {
		this.clinic = clinic;
	}

	@JsonFormat(pattern = "yyyy-MM-dd")
	@ExcelField(title="预约日期", sort=5, dataFormat="yyyy-MM-dd")
	public Date getScheduledTime() {
		return scheduledTime;
	}

	public void setScheduledTime(Date scheduledTime) {
		this.scheduledTime = scheduledTime;
	}

	@ExcelField(title="预约科室", sort=6, dictType="fl_department")
	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	@ExcelField(title="预约状态", sort=7, dictType="fl_appointment_status")
	public String getAppointmentStatus() {
		return appointmentStatus;
	}

	public void setAppointmentStatus(String appointmentStatus) {
		this.appointmentStatus = appointmentStatus;
	}

	@ExcelField(title="上下午", sort=8, dictType="fl_am_pm")
	public String getAmpm() {
		return ampm;
	}

	public void setAmpm(String ampm) {
		this.ampm = ampm;
	}

	@ExcelField(title="医师", sort=9)
	public Doctor getDoctor() {
		return doctor;
	}

	public void setDoctor(Doctor doctor) {
		this.doctor = doctor;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="确认时间", sort=10, dataFormat="yyyy-MM-dd HH:mm:ss")
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public List<ActionRecord> getRecords() {
		return records;
	}

	public void setRecords(List<ActionRecord> records) {
		this.records = records;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	@ExcelField(title="预约编号", sort=1)
	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}

	public List<Evaluate> getEvaluateList() {
		return evaluateList;
	}

	public void setEvaluateList(List<Evaluate> evaluateList) {
		this.evaluateList = evaluateList;
	}

	public List<EvaluateDetail> getEvaluateDetailList() {
		return evaluateDetailList;
	}

	public void setEvaluateDetailList(List<EvaluateDetail> evaluateDetailList) {
		this.evaluateDetailList = evaluateDetailList;
	}

	public String getTimePeriod() {
		return timePeriod;
	}

	public void setTimePeriod(String timePeriod) {
		this.timePeriod = timePeriod;
	}
	
	public String getScore1() {
		return score1;
	}

	public void setScore1(String score1) {
		this.score1 = score1;
	}

	public String getScore2() {
		return score2;
	}

	public void setScore2(String score2) {
		this.score2 = score2;
	}

	public String getScore3() {
		return score3;
	}

	public void setScore3(String score3) {
		this.score3 = score3;
	}

	public String getScore4() {
		return score4;
	}

	public void setScore4(String score4) {
		this.score4 = score4;
	}

	public String getEvaluateDetail() {
		return evaluateDetail;
	}

	public void setEvaluateDetail(String evaluateDetail) {
		this.evaluateDetail = evaluateDetail;
	}

	public String getIsEvaluate() {
		return isEvaluate;
	}

	public void setIsEvaluate(String isEvaluate) {
		this.isEvaluate = isEvaluate;
	}

	public String getEvaluateLevel() {
		return evaluateLevel;
	}

	public void setEvaluateLevel(String evaluateLevel) {
		this.evaluateLevel = evaluateLevel;
	}

	public Date getFinishTime() {
		return finishTime;
	}

	public void setFinishTime(Date finishTime) {
		this.finishTime = finishTime;
	}


	public String getIsEndPoorRating() {
		return isEndPoorRating;
	}

	public void setIsEndPoorRating(String isEndPoorRating) {
		this.isEndPoorRating = isEndPoorRating;
	}
}
